{extend name="../../admin/view/main"}

{block name="button"}
<!--{if auth("add")}-->
<button class='layui-btn layui-btn-sm layui-btn-primary' data-open='{:url("add")}'>添加商品</button>
<!--{/if}-->

{if isset($type) and $type eq 'index'}
<!--{if auth("remove")}-->
<button class='layui-btn layui-btn-sm layui-btn-primary' data-action='{:url("remove")}' data-rule="code#{key};deleted#1">删除商品</button>
<!--{/if}-->
{else}
<!--{if auth("remove")}-->
<button class='layui-btn layui-btn-sm layui-btn-primary' data-action='{:url("remove")}' data-confirm="确定要恢复这些数据吗？" data-rule="code#{key};deleted#0">恢复商品</button>
<!--{/if}-->
{/if}

<!--{if auth("goods.mark/index")}-->
<button class='layui-btn layui-btn-sm layui-btn-primary' data-modal='{:url("shop.mark/index")}' data-title="标签管理" data-width="920px">标签管理</button>
<!--{/if}-->
{/block}

{block name="content"}
<div class="layui-tab layui-tab-card think-bg-white">
    <ul class="layui-tab-title">
        {foreach ['index'=>'商品管理','recycle'=>'回 收 站'] as $k=>$v}
        {if isset($type) and $type eq $k}
        <li class="layui-this" data-open="{:url('index')}?type={$k}">{$v}</li>
        {else}
        <li data-open="{:url('index')}?type={$k}">{$v}</li>
        {/if}{/foreach}
    </ul>
    <div class="layui-tab-content">
        {include file='shop/goods/index_search'}
        <table class="layui-table margin-top-10" lay-skin="line">
            {notempty name='list'}
            <thead>
            <tr>
                <th class='list-table-check-td think-checkbox'>
                    <label><input data-auto-none data-check-target='.list-check-box' type='checkbox'></label>
                </th>
                <th class='list-table-sort-td'>
                    <button class="layui-btn layui-btn-xs" data-reload type="button">刷 新</button>
                </th>
                <th class='text-left nowrap'>商品信息</th>
                <th class='text-left nowrap'></th>
                <th class='text-left nowrap'>商品状态</th>
                <th></th>
            </tr>
            </thead>
            {/notempty}
            <tbody>
            {foreach $list as $key=>$vo}
            <tr>
                <td class='list-table-check-td think-checkbox'>
                    <label><input class="list-check-box" type='checkbox' value='{$vo.code}'></label>
                </td>
                <td class='list-table-sort-td'>
                    <label><input class="list-sort-input" data-action-blur="{:sysuri()}" data-loading="false" data-value="id#{$vo.id};action#sort;sort#{value}" value="{$vo.sort}"></label>
                </td>
                <td class='nowrap'>
                    {notempty name='vo.cover'}
                    <div class="headimg headimg-no" data-tips-hover data-tips-image data-lazy-src="{$vo.cover}"></div>
                    {/notempty}
                    <div class="inline-block sub-span-blue">
                        <div>商品名称：<span>{$vo.name|default='--'}</span></div>
                        <div>商品编号：<span>{$vo.code|default='--'}</span></div>
                    </div>
                </td>
                <td>
                    <div>
                        {notempty name='vo.marks'}{foreach $vo.marks as $mark}
                        <span class="notselect nowrap layui-badge layui-bg-cyan">{$mark}</span>
                        {/foreach}{/notempty}
                    </div>
                    <div class="nowrap">
                        {notempty name='vo.cateinfo'}
                        {:join('<span class="layui-icon layui-icon-right font-s10 color-blue"></span>', $vo.cateinfo.names)}
                        {/notempty}
                    </div>
                </td>
                <td class='nowrap'>
                    累计库存 <b>{$vo.stock_total}</b> 件，剩余库存 <b>{$vo.stock_total-$vo.stock_sales}</b> 件 ( 已销售 <b>{$vo.stock_sales}</b> 件 )
                    <div class="notselect margin-top-5">
                        {eq name='vo.status' value='0'}<span class="layui-badge layui-bg-gray layui-border-red">已下架</span>{else}<span class="layui-badge layui-bg-gray layui-border-green">销售中</span>{/eq}
                        {eq name='vo.vip_entry' value='0'}<span class="layui-badge layui-bg-gray layui-border-blue">非入会礼包</span>{else}<span class="layui-badge layui-bg-gray layui-border-green">是入会礼包</span>{/eq}
                        {eq name='vo.truck_type' value='0'}<span class="layui-badge layui-bg-gray layui-border-blue">无需发货</span>{else}<span class="layui-badge layui-bg-gray layui-border-green">需要发货</span>{/eq}
                        {eq name='vo.rebate_type' value='0'}<span class="layui-badge layui-bg-gray layui-border-blue">非返利商品</span>{else}<span class="layui-badge layui-bg-gray layui-border-green">是返利商品</span>{/eq}
                    </div>
                </td>
                <td class='nowrap sub-strong-blue'>

                    <!--{if auth('copy')}-->
                    <a class="layui-btn layui-btn-xs layui-btn-normal" data-open='{:url("copy")}?code={$vo.code}'>复 制</a>
                    <!--{/if}-->

                    <!--{if auth("edit")}-->
                    <a class="layui-btn layui-btn-xs" data-open='{:url("edit")}?code={$vo.code}'>编 辑</a>
                    <!--{else}-->
                    <a class="layui-btn layui-btn-xs layui-btn-primary layui-disabled" data-tips-text="您没有编辑商品的权限哦！">编 辑</a>
                    <!--{/if}-->

                    {if isset($type) and $type eq 'index'}
                    {if isset($vo.status) and $vo.status eq 1}
                    <!--{if auth("state")}-->
                    <a class="layui-btn layui-btn-xs layui-btn-warm" data-action="{:url('state')}" data-value="code#{$vo.code};status#0">下 架</a>
                    <!--{else}-->
                    <a class="layui-btn layui-btn-xs layui-btn-primary layui-disabled" data-tips-text="您没有下架商品的权限哦！">下 架</a>
                    <!--{/if}-->
                    {else}
                    <!--{if auth("state")}-->
                    <a class="layui-btn layui-btn-xs layui-btn-warm" data-action="{:url('state')}" data-value="code#{$vo.code};status#1">上 架</a>
                    <!--{else}-->
                    <a class="layui-btn layui-btn-xs layui-btn-primary layui-disabled" data-tips-text="您没有上架商品的权限哦！">上 架</a>
                    <!--{/if}-->
                    {/if}
                    <!--{if auth("stock")}-->
                    <a class="layui-btn layui-btn-xs layui-btn-normal" data-modal='{:url("stock")}?code={$vo.code}' data-title="商品入库">入 库</a>
                    <!--{else}-->
                    <a class="layui-btn layui-btn-xs layui-btn-primary layui-disabled" data-tips-text="您没有商品入库的权限哦！">入 库</a>
                    <!--{/if}-->
                    <!--{if auth("remove")}-->
                    <a class="layui-btn layui-btn-xs layui-btn-danger" data-action="{:url('remove')}" data-confirm="确定要移入回收站吗？" data-value="code#{$vo.code};deleted#1">删 除</a>
                    <!--{/if}-->
                    {else}
                    <!--{if auth("remove")}-->
                    <a class="layui-btn layui-btn-xs layui-btn-normal" data-action="{:url('remove')}" data-value="code#{$vo.code};deleted#0">恢 复</a>
                    <!--{/if}-->
                    {/if}
                </td>
            </tr>
            {/foreach}
            </tbody>
        </table>
        {empty name='list'}<span class="notdata">没有记录哦</span>{else}{$pagehtml|raw|default=''}{/empty}
    </div>
</div>
{/block}